package cn.tedu.csmailproduct.controller;

import cn.tedu.csmailproduct.ex.ServiceException;
import cn.tedu.csmailproduct.pojo.dto.AlbumAddNewDTO;
import cn.tedu.csmailproduct.pojo.dto.BrandAddNewDTO;
import cn.tedu.csmailproduct.service.IAlbumService;
import cn.tedu.csmailproduct.service.IBrandService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 处理品牌相关请求的控制器
 *
 * @author java@qq.com
 * @version 0.0.1
 *
 */

@Api(tags = "02. 品牌管理模块")
@Slf4j
@RestController
@RequestMapping("/brands")
public class BrandController {

    @Autowired
    private IBrandService BrandService;

    public BrandController(){
        log.debug("创建控制器对象：BrandController");
    }

    // http://localhost:8080//brands/add-new?name=品牌001&description=品牌001的简介&sort=199
    @ApiOperation("添加品牌")
    @ApiOperationSupport(order = 100)
    @PostMapping("/add-new")
    public String addNew(BrandAddNewDTO brandAddNewDTO){
        log.debug("开始处理【添加品牌】的请求，参数：{}：",brandAddNewDTO);

            BrandService.addNew(brandAddNewDTO);
            log.debug("添加数据成功");
            return "添加品牌成功！";

    }

}
